define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'air/charter_quote/index' + location.search,
                    add_url: 'air/charter_quote/add',
                    edit_url: 'air/charter_quote/edit',
                    // del_url: 'air/charter_quote/del',
                    multi_url: 'air/charter_quote/multi',
                    import_url: 'air/charter_quote/import',
                    table: 'air_charter_quote',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'cc.plan_name', title: __('飞机名称')},
                        {field: 'scity.shortname', title: __('起飞点 ')},
                        {field: 'ecity.shortname', title: __('降落点')},
                        {field: 'flight_date', title: __('Flight_date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'contactor', title: __('Contactor'), operate: 'LIKE'},
                        {field: 'phone', title: __('Phone'), operate: 'LIKE'},
                        {field: 'company', title: __('Company'), operate: 'LIKE'},
                        {field: 'note', title: __('Note'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'quote_status', title: __('Quote_status'), searchList: {"1":__('Quote_status 1'),"2":__('Quote_status 2'),"3":__('Quote_status 3'),"4":__('Quote_status 4')}, formatter: Table.api.formatter.status, custom: {'1':'info', '2':'gray', '3': 'success', '4': 'danger'}},
                        {field: 'handle_note', title: __('处理内容'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'handle_time', title: __('处理时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ],
                showToggle: false,
                showColumns: false,
                showExport: false,
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
